package cn.chinaflame.pagodas.web;

import cn.chinaflame.pagodas.req.PaGreetingsReq;
import cn.chinaflame.pagodas.service.PaGreetingsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * Created by yw on 2018/9/27.
 */

@RestController
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "openapi/v1/pagodas/pagreetings/")
public class OpenPaGreetingsAPI {

    private static Logger log = LoggerFactory.getLogger(OpenPaGreetingsAPI.class);
    @Autowired
    private PaGreetingsService paGreetingsService;

    /**
     * 祝福语添加接口
     * @param req
     * @return
     */
    @PostMapping("add")
    public Object add (@RequestBody PaGreetingsReq req) {
        log.info("祝福语添加接口req:{}", req);
        return paGreetingsService.add(req);
    }

    /**
     * 祝福语修改接口
     * @param req
     * @return
     */
    @PostMapping("update")
    public Object update (@RequestBody PaGreetingsReq req) {
        log.info("祝福语修改接口req:{}", req);
        return paGreetingsService.update(req);
    }

    /**
     * 祝福语删除接口
     * @param id
     * @return
     */
    @DeleteMapping("delete/{id}")
    public Object delete (@PathVariable("id") Integer id) {
        log.info("祝福语删除接口id:{}", id);
        return paGreetingsService.delete(id);
    }

    /**
     * 祝福语查看详情接口
     * @param id
     * @return
     */
    @GetMapping("query")
    public Object query (Integer id) {
        log.info("祝福语查看详情接口id:{}",id);
        return paGreetingsService.query(id);
    }

    /**
     * 祝福语List查询接口
     * @param req
     * @return
     */
    @GetMapping("list")
    public Object list (String pageIndex,String pageSize,String id, String greetings) {
        log.info("祝福语List查看接口pageIndex:{},pageSize:{},id:{},greetings:{}", pageIndex,pageSize,id,greetings);
        return paGreetingsService.list(pageIndex,pageSize,id,greetings);
    }





}
